import circle from '../../api/circle'

const store = {
    state:{
        circleTable:[],
        circleMoment:[],
        showCircleAddDialog: false,
        circleEditData:''
    },
    getters: {
       getCircleTable: state => state.circleTable,
       getCircleMoment: state => state.circleMoment
    },
    mutations: {
        getCircleTable(state, circleTable){
            state.circleTable = circleTable;
        },
        checkoutMoment(state, circleMoment){
            state.circleMoment =circleMoment;
        },
        changeCircleData(state, data){
            state.circleEditData = data;
        },
        addCircleMoment(state,data){
           state.circleMoment = state.circleMoment.concat(data);
           
        }
    },
    actions: {
        getCircleTable({commit},pageNum){
            circle.getCircleTable(circleTable =>{
                commit('getCircleTable',circleTable)
            },pageNum)
        },
        getCircleMoment({commit}, data){
            circle.getCircleMoment(circleMoment =>{
                commit('checkoutMoment',circleMoment)
            })
        },
        createCircle({commit}, circleData){
            circle.createCircle(circleData);
        },
        changeCircleData({commit}, data){
            commit('changeCircleData',data)
        },
        addCircleMoment({commit}){
              circle.getCircleMoment(circleMoment =>{
                commit('addCircleMoment',circleMoment)
            })
        }
    }
}

export default store;